package com.adv.ems.controller.admin;

import com.adv.ems.constants.SystemConst;
import com.adv.ems.model.dto.APIRequest;
import com.adv.ems.model.dto.APIResponse;
import com.adv.ems.model.param.BaseQueryParam;
import com.adv.ems.model.vo.BaseGatewayVO;
import com.adv.ems.service.BaseDataService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/ems/client/base/gateway")
public class GatewayController {
    @Resource
    BaseDataService baseDataService;

    @PostMapping("/list")
    public APIResponse<BaseGatewayVO> list(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                         @RequestBody APIRequest<BaseQueryParam> request) {
        return APIResponse.<BaseGatewayVO>build().content(baseDataService.gatewayList(request.getContent(), acceptLanguage));
    }

    @PostMapping("/update")
    public APIResponse<Boolean> update(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                       @RequestBody APIRequest<BaseGatewayVO.Info> request) {
        return APIResponse.<Boolean>build().content(baseDataService.gatewayUpdate(request.getContent(), acceptLanguage));
    }
}
